﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Transformer.iHunter
{
    /// <summary>
    /// Expose the API of client to the GUI
    /// </summary>
    public interface IClientCore : IDisposable
    {
        IFolder RootFolder { get; }

        IFolder FindFolderByGuid(Guid guid);
        IFolder FindFolderByName(string name, Guid parentGuid);


        IFolder[] GetSubFolders(Guid parentGuid);
        Guid NewFolder(IFolder folder, Guid parentGuid);
        bool StoreFolder(IFolder folder);
        void DeleteFolder(Guid guid);
        void MoveFolder(Guid folderGuid, Guid newParentGuid);
        Guid CopyFolder(Guid folderGuid, Guid newParentGuid);
  
        Guid NewMessage(IMessage messgae, Guid folderGuid);
        IMessage FindMessageByGuid(Guid guid);
        IMessage[] GetMessageHeaders(Guid folderGuid);
        void MoveMessage(Guid guid, Guid folderGuid);
        Guid CopyMessage(Guid guid, Guid folderGuid);
        void StoreMessage(IMessage message);
        void DeleteMessage(Guid guid);
   
        int GetUnreadMessageCount(Guid folderGuid, bool recursive);
        void MarkAllMessages(Guid folderGuid, bool read);

        void StoreMessageHeader(IMessage message);


        /// <summary>
        /// Synchronizes all
        /// </summary>
        void SynchronizeAll();

        /// <summary>
        /// Synchronizes the folder.
        /// </summary>
        /// <param name="guid">The GUID of the folder.</param>
        void SynchronizeFolder(Guid guid);

        /// <summary>
        /// Synchronizes the message.
        /// </summary>
        /// <param name="guid">The GUID.</param>
        void SynchronizeMessage(Guid guid);


        /// <summary>
        /// Creates the database.
        /// </summary>
        void CreateMasterDatabase();


        /// <summary>
        /// Initializes this instance.
        /// </summary>
        void Initailize();



        /// <summary>
        /// Gets or sets the global settings.
        /// </summary>
        /// <value>The global settings.</value>
        string GlobalSettings { get; set; }

        /// <summary>
        /// Gets the database manager.
        /// </summary>
        /// <value>The database manager.</value>
        IDatabaseManager DatabaseManager { get; }

        /// <summary>
        /// Occurs when error occurs.
        /// </summary>
        event PluginErrorEventHandler ErrorOccur;

        /// <summary>
        /// Cancels the blocking call.
        /// </summary>
        void CancelBlockingCall();

        /// <summary>
        /// Search by title and author
        /// </summary>
        IMessage[] Search(string title, string author, bool unreadonly);

        event MessageEventHandler MessageChanged;
        event FolderEventHandler FolderChanged;
    }
}
